package org.example.domain;

import org.example.enums.OperEnum;

public enum CountSingleton {

    INSTANCE(10);

    private Integer count;

    CountSingleton(int count) {
        this.count = count;
    }

    public static CountSingleton getInstance() {
        return INSTANCE;
    }

    public static Integer getCount() {
        return getInstance().count;
    }

    public static synchronized void setCount(OperEnum operEnum) {
        if (operEnum == OperEnum.ADD) {
            INSTANCE.count++;
        }
        if (operEnum == OperEnum.SUB) {
            INSTANCE.count--;
        }
    }
}
